package com.yitiao.data_algorithms.leetcode.editor.cn;

import com.yitiao.data_algorithms.leetcode.editor.cn.base.ListNode;
import com.yitiao.data_algorithms.leetcode.editor.cn.base.TreeNode;

class IntegerBreak {
    // 2022-09-05 11:33:21
    public static void main(String[] args) {
        Solution solution = new IntegerBreak().new Solution();
        solution.integerBreak(10);
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int integerBreak(int n) {
            if (n <= 3) return n-1;
            int[] dp = new int[n + 1];
            dp[2] = 2;
            dp[3] = 3;
            for (int i = 4; i <= n; i++) {
                for (int j = 2; j <= i / 2; j++) {
                    dp[i] = Math.max(dp[i], dp[j] * dp[i - j]);
                }
            }
            return dp[n];
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}